home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CDPD Public Domain Collection for CDTV 4
/
CDPD_IV.bin
/
e
/
mailinglists
/
amigae.0993sept.archive
/
000064_crash!MSUVX1.M….EDU!UMLANGSTON_Sat, 25 Sep 93 02:47:46 PST.msg
< prev
next >
Wrap
Internet Message Format
|
1994-05-26
|
2KB
Received: by bkhouse.cts.com (V1.16/Amiga)
id AA00000; Sat, 25 Sep 93 02:47:46 PST
Received: from msuvx1.memst.edu by crash.cts.com with smtp
(Smail3.1.28.1 #18) id m0ogKly-0000OFC; Fri, 24 Sep 93 14:33 PDT
Received: from MSUVX1.MEMST.EDU by MSUVX1.MEMST.EDU (PMDF V4.2-14 #3869) id
<01H3BZYXK3UO9KNLOE@MSUVX1.MEMST.EDU>; Fri, 24 Sep 1993 16:36:30 CST
Date: Fri, 24 Sep 1993 16:36:30 -0600 (CST)
Message-id: <01H3BZYXLG369KNLOE@MSUVX1.MEMST.EDU>
X-VMS-To: IN%"amigae@bkhouse.cts.com"
MIME-version: 1.0
Content-type: TEXT/PLAIN; CHARSET=US-ASCII
Content-transfer-encoding: 7BIT
From: UMLANGSTON@MSUVX1.MEMST.EDU
To: amigae@bkhouse.cts.com
Subject: Random numbers
Okay people, I have a problem.
I'm tryring to generate random numbers. Here's the story:
Using code that Barry supplied, I have a 2D matrix, 500x70, set up. I
want to go through each cell in the matrix and randomly put a value
between -40 and 40. When I say RANDOMLY, I mean: A uniform random sample
from the set [-40..40]. Here's what I tried (in psuedocode):
FOR x:=0 TO 499
FOR y:=0 TO 69 /* Remember, Barry: this is psuedocode... :) */
c:=Rnd(80)
c:=c-40
array[x,y]:=c
ENDFOR
ENDFOR
Again, in psudocode, here's how I read it back out:
FOR x:=0 to 499
FOR y:=0 to 69
IF array[x,y]<0 THEN WriteF('0') ELSE WriteF('1')
ENDFOR
ENDFOR
This should print out lines of length 70, containing a random sample from
the boolean set [0,1]^70. However, All I get are vectors containing all '1's.
What gives?
Does anyone have a code solution for this, or some mathematics for a more
statistically-pure uniform random sampling procedure? This is gonna drive
me up the wall!
To make things worse, I wrote a little program called test.e. Here it is:
PROC main()
DEF a,x
For x:=0 to 10000
a:=Rnd(1000)
IF a<500 THEN WriteF('0') ELSE WriteF('1')
ENDFOR
ENDPROC
Works just fine!!! I don't get it. Barry, could this be a problem with how
your array routines store integers (positive versus negative?) I'm confused.
hopefully,
mark